<?php

/**
 * This is the model class for table "applicants".
 *
 * The followings are the available columns in table 'applicants':
 * @property integer $id
 * @property string $name
 * @property string $sname
 * @property string $birthday
 * @property string $gender
 * @property string $nationality
 * @property string $address
 * @property string $phone
 * @property string $email
 * @property string $id_type
 * @property string $id_number
 * @property string $given_place
 * @property string $given_date
 * @property string $photo
 * @property string $school_city
 * @property string $school_name
 * @property string $ent_score
 * @property string $at_id
 * @property string $at_date
 * @property string $at_type
 * @property string $payment
 * @property string $faculty
 * @property string $spec
 * @property string $lang
 * @property string $date_entry
 * @property string $level
 * @property string $year
 * @property string $fname
 * @property string $fphone
 * @property string $femail
 * @property string $fjob
 * @property string $mname
 * @property string $mphone
 * @property string $memail
 * @property string $mjob
 */
class Students extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Students the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'applicants';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('name, sname, birthday, gender, nationality, address, phone, email, id_type, id_number, given_place, given_date, photo, school_city, school_name, ent_score, at_id, at_date, at_type, payment, faculty, spec, lang, date_entry, level, year, fname, fphone, femail, fjob, mname, mphone, memail, mjob', 'required'),
			array('name, sname, birthday, gender, nationality, address, phone, email, id_type, id_number, given_place, given_date, photo, school_city, school_name, ent_score, at_id, at_date, at_type, payment, faculty, spec, lang, date_entry, fname, fphone, femail, fjob, mname, mphone, memail, mjob', 'length', 'max'=>256),
			array('level', 'length', 'max'=>50),
			array('year', 'length', 'max'=>5),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, name, sname, birthday, gender, nationality, address, phone, email, id_type, id_number, given_place, given_date, photo, school_city, school_name, ent_score, at_id, at_date, at_type, payment, faculty, spec, lang, date_entry, level, year, fname, fphone, femail, fjob, mname, mphone, memail, mjob', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'name' => 'Name',
			'sname' => 'Sname',
			'birthday' => 'Birthday',
			'gender' => 'Gender',
			'nationality' => 'Nationality',
			'address' => 'Address',
			'phone' => 'Phone',
			'email' => 'Email',
			'id_type' => 'Id Type',
			'id_number' => 'Id Number',
			'given_place' => 'Given Place',
			'given_date' => 'Given Date',
			'photo' => 'Photo',
			'school_city' => 'School City',
			'school_name' => 'School Name',
			'ent_score' => 'Ent Score',
			'at_id' => 'At',
			'at_date' => 'At Date',
			'at_type' => 'At Type',
			'payment' => 'Payment',
			'faculty' => 'Faculty',
			'spec' => 'Spec',
			'lang' => 'Lang',
			'date_entry' => 'Date Entry',
			'level' => 'Level',
			'year' => 'Year',
			'fname' => 'Fname',
			'fphone' => 'Fphone',
			'femail' => 'Femail',
			'fjob' => 'Fjob',
			'mname' => 'Mname',
			'mphone' => 'Mphone',
			'memail' => 'Memail',
			'mjob' => 'Mjob',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('name',$this->name,true);
		$criteria->compare('sname',$this->sname,true);
		$criteria->compare('birthday',$this->birthday,true);
		$criteria->compare('gender',$this->gender,true);
		$criteria->compare('nationality',$this->nationality,true);
		$criteria->compare('address',$this->address,true);
		$criteria->compare('phone',$this->phone,true);
		$criteria->compare('email',$this->email,true);
		$criteria->compare('id_type',$this->id_type,true);
		$criteria->compare('id_number',$this->id_number,true);
		$criteria->compare('given_place',$this->given_place,true);
		$criteria->compare('given_date',$this->given_date,true);
		$criteria->compare('photo',$this->photo,true);
		$criteria->compare('school_city',$this->school_city,true);
		$criteria->compare('school_name',$this->school_name,true);
		$criteria->compare('ent_score',$this->ent_score,true);
		$criteria->compare('at_id',$this->at_id,true);
		$criteria->compare('at_date',$this->at_date,true);
		$criteria->compare('at_type',$this->at_type,true);
		$criteria->compare('payment',$this->payment,true);
		$criteria->compare('faculty',$this->faculty,true);
		$criteria->compare('spec',$this->spec,true);
		$criteria->compare('lang',$this->lang,true);
		$criteria->compare('date_entry',$this->date_entry,true);
		$criteria->compare('level',$this->level,true);
		$criteria->compare('year',$this->year,true);
		$criteria->compare('fname',$this->fname,true);
		$criteria->compare('fphone',$this->fphone,true);
		$criteria->compare('femail',$this->femail,true);
		$criteria->compare('fjob',$this->fjob,true);
		$criteria->compare('mname',$this->mname,true);
		$criteria->compare('mphone',$this->mphone,true);
		$criteria->compare('memail',$this->memail,true);
		$criteria->compare('mjob',$this->mjob,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}